
require "util";
require "logUtil";
require "setting"



xunFang={}

function xunFang.ui()
x, y = findMultiColorInRegionFuzzy(0xfed738,"-33|-4|0x99140b,3|-35|0x94100a,29|-62|0x69381e,-365|1|0x3b0b00,-448|-11|0xfef9c8,-505|0|0xfee9a0,-495|1|0xfee89c,-471|-17|0xfefed6,-474|-5|0xfef1b4,-456|9|0xfede7f,-450|-10|0xfef7c5,-494|11|0x3a0b00", 85, 381, 7, 1077, 259, 0, 0)

  if x > -1 then
    logger("寻访.界面", LOG_DEBUG)
    return true
  end

end


function xunFang.close()
  x, y = findMultiColorInRegionFuzzy(0xfed738,"-33|-4|0x99140b,3|-35|0x94100a,29|-62|0x69381e,-365|1|0x3b0b00,-448|-11|0xfef9c8,-505|0|0xfee9a0,-495|1|0xfee89c,-471|-17|0xfefed6,-474|-5|0xfef1b4,-456|9|0xfede7f,-450|-10|0xfef7c5,-494|11|0x3a0b00", 85, 381, 7, 1077, 259, 0, 0)

  if x > -1 then
    click(x, y)
    logger("寻访.界面关闭", LOG_DEBUG)
    return true
  end

end


function xunFang.xunFang()

  x, y = findMultiColorInRegionFuzzy(0xc56b2c,"140|-4|0xc46a2c,178|52|0x824816,-44|52|0x7e4515,-79|29|0x000000,24|-38|0x000000,49|81|0x000000,214|26|0x000000", 85, 740, 1761, 1062, 1907, 0, 0)
  if x > -1 then
    click(x, y)
    logger("寻访.寻访", LOG_DEBUG)
    return true
  end
end

function xunFang.tiaoGuo()
  click( 1069,1656)

end

function xunFang.huiFuTiLi()

  x, y = findMultiColorInRegionFuzzy(0xa71006,"167|-7|0xc72508,181|45|0x610000,-14|44|0x640000,105|10|0xfff7d6,137|11|0xfff7d6,29|8|0xfff7d6,29|8|0xfff7d6,105|28|0xfff7d6,66|31|0xfff7d6", 85, 735, 1758, 1067, 1910, 0, 0)
  if x==-1 then
    x, y = findMultiColorInRegionFuzzy(0xa60f06,"173|-8|0xad1306,-26|44|0x660100,196|45|0x6b0000,-41|-71|0x1a0804,163|-74|0x1b0904,-6|93|0x5c2619,158|92|0x5c2619,64|-31|0x690c00,-49|4|0x690c00", 92, 683, 1712, 1070, 1895, 0, 0)
  end
  if x > -1 then
    logger("寻访.没体力了", LOG_DEBUG)
    return true
  end

end

function xunFang.run()
  ZhuJieMian.xunFang()

  flag=xunFang.ui()
  if  not(flag) then
    return
  end


  local funcArr={xunFang.xunFang,xunFang.tiaoGuo}


  while flag do
    for i, func in ipairs(funcArr) do
      func();
      mSleep(100)
    end

    mSleep(5000)
    flag =xunFang.huiFuTiLi()
    flag =not(flag)
  end

  mSleep(300)
xunFang.close()

end
